from selenium import webdriver
import time,unittest
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

class Ctrip(unittest.TestCase):

    def test_01(self):
       # 打开edge浏览器
       self.driver = webdriver.Edge()
       # 打开携程网站
       self.driver.get('https://www.ctrip.com/')
       # 窗口最大化
       self.driver.maximize_window()
       # 1点击登录
       login = self.driver.find_element(By.XPATH, '//*[@id="hp_nfes_accountbar"]/li[1]/div/button/div/span')
       # 鼠标左键单击
       ActionChains(self.driver).click(login).perform()
       time.sleep(3)
       # 2输入用户名
       self.driver.find_element(By.XPATH, '//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[1]/dd/input').send_keys('15523615751')
       time.sleep(3)
       # 3输入密码
       self.driver.find_element(By.XPATH,'//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[2]/dd/input').send_keys('lj070130.')
       time.sleep(3)
       # 4勾选协议,鼠标三击
       xy = self.driver.find_element(By.XPATH, '//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[4]/div/div[1]/label')
       ActionChains(self.driver).double_click(xy).click(xy).perform()
       time.sleep(3)
       # 5点击登录
       self.driver.find_element(By.XPATH, '//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[3]/dd/input').click()
       time.sleep(30)
       # 鼠标释放
       ActionChains(self.driver).release()
       # 文本断言首页
       dy = self.driver.find_element(By.CLASS_NAME, 'tl_icon_content_qbOk8').text
       self.assertEqual('首页', dy)
